package cn.touna.jss.common.dict.enums;

import java.util.HashMap;
import java.util.Map;

public enum IntfStatusEnum {

    VALID(1, "有效"),
    INVALID(0, "停用"),
    STOPUSING(2, "欠费"),
    NOAUTH(3, "无权限访问");

    /**
     * 枚举值
     */
    private final int value;

    /**
     * 枚举文本
     */
    private final String text;

    IntfStatusEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    /**
     * {@inheritDoc}
     */
    public int value() {
        return value;
    }

    /**
     * 获取枚举对象文本
     *
     * @return String
     */
    public String text() {
        return text;
    }

    /**
     * 根据值获取枚举对象
     *
     * @param value 枚举值
     * @return 对象枚举对象
     */
    public static IntfStatusEnum getloanStatus(int value) {
        for (IntfStatusEnum status : values()) {
            if (status.value()==value) {
                return status;
            }
        }
        return null;
    }


    /**
     * 根据code获取值
     *
     * @param code 枚举值
     * @return 对象枚举对象
     */
    public static String getValue(int value) {
        for (IntfStatusEnum status : values()) {
            if (status.value()== value) {
                return status.text();
            }
        }
        return "";
    }


    /**
     * ENUM 转换成MAP
     */
    private static final Map<String, String> riskStatusMap = new HashMap<String, String>();




    public static void main(String[] args) {
//    	  BaiRongResultEnum getloanStatus = BaiRongResultEnum.getloanStatus("1");
//    	  System.out.println(getloanStatus.value());
//    	  System.out.println(getloanStatus.text());
//        getloanStatus("0");
//        Iterator<String> iterator = riskStatusMap.keySet().iterator();
//        while (iterator.hasNext()){
//            String key = iterator.next();
//            System.out.print("key:"+ key);
//            System.out.println(" value:"+riskStatusMap.get(key));
//        }
//         String value = getValue("1");
//        System.out.println(" value:" + BaiRongResultEnum.success.text());


    }


}
